add Method (Combo) |
This method adds a DIV element to the combo box.
Syntax
var oAddedElement = comboID.add(vItem, [sValue])
Parameters
Parameter |
Description |
---|---|
vItem |
Required. String or Object that denotes the item to be added. If this is string then this will be the name if the item added, else this will be the DIV object that is to be added. |
sValue |
Optional. String that denotes the value of the item to be added. |
Return Value
No return value.
Example
The following example shows how this method can be used to add an item to the combo box.
//JScript function to add item to combo box function addItem() { //The name of the combo box is 'myCombo' myCombo.add("New Item", "New Value"); //Create a DIV element and pass an object as input var newItem = window.document.createElement("DIV"); newItem.innerHTML = "New Item"; newItem.value = "New Value"; //Add the new item myCombo.add(newItem); }